import { getUser } from "@/api/user"
import router from "@/router"
import store from "@/store"
export async function refreshUser () {
	const res = await getUser()
	if (res.code === 200 && res.data) {
		localStorage.setItem('user', JSON.stringify(res.data))
		store.commit('setUser', res.data)
	} else {
		localStorage.clear()
		router.push('/login')
		store.commit('setUser', {})
	}
}